home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 1.8 KB | 76 lines | [TEXT/MPS ] |
- ; example GetNextEvent filter (using jGNEFilter)
- ; Steve Falkenburg 10/9/91
- ;
- ; this sample installs a global GetNextEvent filter using the
- ; mechanism described in Tech Note #85
- ;
- ; this filter beeps the speaker whenever a key is pressed with the shift key down
- ;
- ; make sure the system heap bit and locked bit are set for this code resource!
- ;
-
- include 'ToolEqu.a'
- include 'SysEqu.a'
- include 'Traps.a'
- include 'QuickEqu.a'
- include 'sysErr.a'
-
- ; jGNE a6 stack offsets
- eventResult equ 8
-
- MAIN proc export
-
- start bra.s setup
-
- ; global data
- ;
- oldGNE ds.l 1
- gneResult ds.w 1
-
- ; GetNextEvent Filter
- ;
- gnePatch link a6,#0 ; link for stack frame
- movem.l d0-d2/a0-a2,-(sp) ; save registers
-
- lea gneResult,a0 ; save old GetNextEvent result
- move.w d0,(a0)
-
- move.w evtNum(a1),d0
- cmpi.w #keyDwnEvt,d0 ; check for keydown and autokey
- beq.s gotkey
- cmpi.w #autoKeyEvt,d0
- bne.s gneDone
-
- gotkey btst #shiftKey,evtMeta(a1) ; check to see if shift key down
- beq.s gneDone
-
- move.w #20,-(sp) ; if so, beep
- _SysBeep
-
- gneDone lea gneResult,a0
- move.w (a0),eventResult(a6)
- move.w d0,eventResult(a6) ; store new boolean result on stack
- movem.l (sp)+,d0-d2/a0-a2 ; restore registers
- unlk a6 ; unlink stack frame
- move.l oldGNE,-(sp) ; get address of original GNE filter
- rts ; return into original GNE filter
-
-
- ; setup code here (INIT time)
-
- setup lea start,a0 ; float ourselves in system heap
- _RecoverHandle ; by calling recoverhandle
- move.l a0,-(sp) ; to get handle
- _DetachResource ; and detachresouce to release ourselves
-
- lea oldGNE,a0 ; patch ourselves into the JGNE chain
- move.l JGNEFilter,(a0)
- lea gnePatch,a0
- move.l a0,d0
- _StripAddress ; you *have* to do this to be 32 bit clean
- move.l d0,JGNEFilter
-
- done rts
- endp
-
- end